{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "fa500c45",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "In E:\\Anaconda\\lib\\site-packages\\matplotlib\\mpl-data\\stylelib\\_classic_test.mplstyle: \n",
      "The text.latex.preview rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.\n",
      "In E:\\Anaconda\\lib\\site-packages\\matplotlib\\mpl-data\\stylelib\\_classic_test.mplstyle: \n",
      "The mathtext.fallback_to_cm rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.\n",
      "In E:\\Anaconda\\lib\\site-packages\\matplotlib\\mpl-data\\stylelib\\_classic_test.mplstyle: Support for setting the 'mathtext.fallback_to_cm' rcParam is deprecated since 3.3 and will be removed two minor releases later; use 'mathtext.fallback : 'cm' instead.\n",
      "In E:\\Anaconda\\lib\\site-packages\\matplotlib\\mpl-data\\stylelib\\_classic_test.mplstyle: \n",
      "The validate_bool_maybe_none function was deprecated in Matplotlib 3.3 and will be removed two minor releases later.\n",
      "In E:\\Anaconda\\lib\\site-packages\\matplotlib\\mpl-data\\stylelib\\_classic_test.mplstyle: \n",
      "The savefig.jpeg_quality rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.\n",
      "In E:\\Anaconda\\lib\\site-packages\\matplotlib\\mpl-data\\stylelib\\_classic_test.mplstyle: \n",
      "The keymap.all_axes rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.\n",
      "In E:\\Anaconda\\lib\\site-packages\\matplotlib\\mpl-data\\stylelib\\_classic_test.mplstyle: \n",
      "The animation.avconv_path rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.\n",
      "In E:\\Anaconda\\lib\\site-packages\\matplotlib\\mpl-data\\stylelib\\_classic_test.mplstyle: \n",
      "The animation.avconv_args rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<module 'get_freq_lpr' from '../traffic_state_lpr\\\\get_freq_lpr.py'>"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import geopandas as gpd\n",
    "from coord_convert.transform import wgs2gcj, wgs2bd, gcj2wgs, gcj2bd, bd2wgs, bd2gcj\n",
    "import matplotlib.pyplot as plt\n",
    "import os\n",
    "import transbigdata as tbd\n",
    "import sys\n",
    "sys.path.append(\"../traffic_state_lpr/\")\n",
    "from datetime import datetime, timezone, timedelta\n",
    "from matplotlib import ticker\n",
    "import get_freq_lpr\n",
    "import copy\n",
    "import time, datetime\n",
    "import importlib\n",
    "importlib.reload(get_freq_lpr)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ff474693",
   "metadata": {},
   "source": [
    "# 1.The average daily total frequency of detection for each grid and time slot\n",
    "## 1.1 Matching the electrical alarm checkpoint equipment with the grid"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "144a598c",
   "metadata": {},
   "outputs": [],
   "source": [
    "get_freq_lpr.get_traf_state.match_dev_grid(dev_file=\"../../data/distinct_camera.xlsx\",\n",
    "                          grid_data_file=\"../../data/ResearchAreaGrid/grid/research_grid.shp\",\n",
    "                          grid_param_file=\"../../data/ResearchAreaGrid/grid_params.npy\",\n",
    "                          dev_grid_match_file=\"../../data/各时间片各栅格交通状态数据/dev_grid_match.csv\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dcb29a37",
   "metadata": {},
   "source": [
    "## 1.2 Total frequency of detection for each time slot and grid"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "85c63f32",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "正在处理0318.csv\n",
      "正在处理0319.csv\n",
      "正在处理0320.csv\n",
      "正在处理0321.csv\n",
      "正在处理0322.csv\n"
     ]
    }
   ],
   "source": [
    "# 提取出各天的各时间片各栅格被检测总频次\n",
    "get_freq_lpr.get_traf_state.get_freq_auto(lpr_data_file_path=\"../../data/萧山市车牌识别数据/\" ,\n",
    "                         dev_grid_match_file=\"../../data/各时间片各栅格交通状态数据/dev_grid_match.csv\",\n",
    "                         data_save_path=\"../../data/各时间片各栅格交通状态数据/各天的状态数据/\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "8376ab0c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "正在处理volumn_data_0318.csv\n",
      "正在处理volumn_data_0319.csv\n",
      "正在处理volumn_data_0320.csv\n",
      "正在处理volumn_data_0321.csv\n",
      "正在处理volumn_data_0322.csv\n"
     ]
    }
   ],
   "source": [
    "# 对各天的各时间片各栅格被检测总频次取均值\n",
    "get_freq_lpr.get_traf_state.get_avg_freq(daily_freq_file_path=\"../../data/各时间片各栅格交通状态数据/各天的状态数据/\",\n",
    "                                avg_freq_file=\"../../data/各时间片各栅格交通状态数据/avg_traffic_freq.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "314956bd",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
